﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;// using Excel

namespace Excel1316AddIn01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnShowTime_Click(object sender, EventArgs e)
        {
            Globals.ThisAddIn.Application.ActiveCell.Value = System.DateTime.Now;
        }

        private void btnSetColor_Click(object sender, EventArgs e)
        {
            Excel.Range rng;// 声明一个Excel的单元格区域变量
            rng = Globals.ThisAddIn.Application.Selection;// 获得Excel所选区域
            rng.Interior.Color = System.Drawing.Color.Yellow;// 设置所选区域底纹颜色为黄色
        }
    }
}
